<?php


namespace app\data\model;

use think\admin\Model;

/**
 * 政策基本信息表
 * Class PolicyBasics
 * @package app\data\model
 */
class PolicyBasics extends Model
{
    // 发布级别
    const RELEASE_LEVEL_MAP        = [
        self::RELEASE_LEVEL_National   => '国家级',
        self::RELEASE_LEVEL_Provincial => '省级',
        self::RELEASE_LEVEL_City       => '市级',
        self::RELEASE_LEVEL_County     => '县级',
//        self::RELEASE_LEVEL_Town       => '乡镇级',
//        self::RELEASE_LEVEL_Village    => '村级',
//        self::RELEASE_LEVEL_Personal   => '个人级',
        self::RELEASE_LEVEL_Other      => '其他',
    ];
    const RELEASE_LEVEL_National   = 1;
    const RELEASE_LEVEL_Provincial = 2;
    const RELEASE_LEVEL_City       = 3;
    const RELEASE_LEVEL_County     = 4;
//    const RELEASE_LEVEL_Town       = 5;
//    const RELEASE_LEVEL_Village    = 6;
//    const RELEASE_LEVEL_Personal   = 7;
    const RELEASE_LEVEL_Other      = 8;

    public function policy()
    {
        return $this->hasOne(DataZhengceku::class, 'id', 'policy_id');
    }

    public static function convertToIdValueArray()
    {
        return array_map(function ($value, $key)
        {
            return ['id' => $key, 'value' => $value];
        }, self::RELEASE_LEVEL_MAP, array_keys(self::RELEASE_LEVEL_MAP));
    }
}
